<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
request.setAttribute("basePath", basePath);
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>博客列表管理</title>
<meta name="description" content="这是一个form页面">
<meta name="keywords" content="form">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="icon" type="image/png" href="${basePath }assets/i/favicon.png">
<link rel="apple-touch-icon-precomposed" href="${basePath }assets/i/app-icon72x72@2x.png">
<meta name="apple-mobile-web-app-title" content="Amaze UI" />
<link rel="stylesheet" href="${basePath }assets/css/amazeui.min.css"/>
<link rel="stylesheet" href="${basePath }assets/css/admin.css">
</head>
<body>
<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
  以获得更好的体验！</p>
<![endif]-->
<header class="am-topbar am-topbar-inverse admin-header">
  <div class="am-topbar-brand">
    <strong>YeZi Guo</strong> <small>后台管理</small>
  </div>

  <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only" data-am-collapse="{target: '#topbar-collapse'}"><span class="am-sr-only">导航切换</span> <span class="am-icon-bars"></span></button>

  <div class="am-collapse am-topbar-collapse" id="topbar-collapse">

    <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list">
      <li><a href="javascript:;"><span class="am-icon-envelope-o"></span> 收件箱 <span class="am-badge am-badge-warning">5</span></a></li>
      <li class="am-dropdown" data-am-dropdown>
        <a class="am-dropdown-toggle" data-am-dropdown-toggle href="javascript:;">
          <span class="am-icon-users"></span> 管理员 <span class="am-icon-caret-down"></span>
        </a>
        <ul class="am-dropdown-content">
          <li><a href="#"><span class="am-icon-user"></span> 资料</a></li>
          <li><a href="#"><span class="am-icon-cog"></span> 设置</a></li>
          <li><a href="#"><span class="am-icon-power-off"></span> 退出</a></li>
        </ul>
      </li>
      <li class="am-hide-sm-only"><a href="javascript:;" id="admin-fullscreen"><span class="am-icon-arrows-alt"></span> <span class="admin-fullText">开启全屏</span></a></li>
    </ul>
  </div>
</header>

<div class="am-cf admin-main">
   <!-- sidebar start -->
  <div class="admin-sidebar am-offcanvas" id="admin-offcanvas">
    <div class="am-offcanvas-bar admin-offcanvas-bar">
      <ul class="am-list admin-sidebar-list">
        <li><a href="admin_index"><span class="am-icon-home"></span> 首页</a></li>
        <li class="admin-parent">
          <a class="am-cf" data-am-collapse="{target: '#collapse-nav'}"><span class="am-icon-file"></span> 页面模块 <span class="am-icon-angle-right am-fr am-margin-right"></span></a>
          <ul class="am-list am-collapse admin-sidebar-sub am-in" id="collapse-nav">
            <li><a href="admin-user.html" class="am-cf"><span class="am-icon-check"></span> 个人资料<span class="am-icon-star am-fr am-margin-right admin-icon-yellow"></span></a></li>
            <li><a href="admin-help.html"><span class="am-icon-puzzle-piece"></span> 帮助页</a></li>
            <li><a href="admin-gallery.html"><span class="am-icon-th"></span> 相册页面<span class="am-badge am-badge-secondary am-margin-right am-fr">24</span></a></li>
            <li><a href="admin-log.html"><span class="am-icon-calendar"></span> 系统日志</a></li>
            <li><a href="admin-404.html"><span class="am-icon-bug"></span> 404</a></li>
          </ul>
        </li>
        <li><a href="admin_articleList"><span class="am-icon-table"></span> 博客列表管理</a></li>
        <li><a href="admin_addArcicleType"><span class="am-icon-pencil-square-o"></span> 添加文章类型</a></li>
        <li><a href="admin_exit"><span class="am-icon-sign-out"></span> 注销</a></li>
      </ul>

      <div class="am-panel am-panel-default admin-sidebar-panel">
        <div class="am-panel-bd">
          <p><span class="am-icon-bookmark"></span> 公告</p>
          <p>时光静好，与君语；细水流年，与君同。—— YeZi Guo</p>
        </div>
      </div>

      <div class="am-panel am-panel-default admin-sidebar-panel">
        <div class="am-panel-bd">
          <p><span class="am-icon-tag"></span> wiki</p>
          <p>Welcome to the YeZi Guo wiki!</p>
        </div>
      </div>
    </div>
  </div>
  <!-- sidebar end -->
  
  
  <!-- content start -->
	<div class="admin-content">
	  <div class="admin-content-body">
	    <div class="am-cf am-padding am-padding-bottom-0">
	      <div class="am-fl am-cf">
	        <strong class="am-text-primary am-text-lg">文章分类</strong> /
	        <small>列表</small>
	      </div>     
	    </div>
	    
		 <hr>
		 
		<div class="am-g">
        <div class="am-u-sm-12 am-u-md-6">
          <div class="am-btn-toolbar">
            <div class="am-btn-group am-btn-group-xs">
              <a href="admin_doSaveArcicle"><button type="button" class="am-btn am-btn-default"><span class="am-icon-plus"></span> 新增</button></a>
             <a href="asd"><button type="button" class="am-btn am-btn-default"><span class="am-icon-trash-o"></span> 删除</button></a>
            </div>
          </div>
        </div>
        <div class="am-u-sm-12 am-u-md-3">
          <div class="am-form-group">
            <select data-am-selected="{btnSize: 'sm'}" id="typeId">
              <option value="-1">所有类别</option>
             	<s:iterator value="#request.types" var="t">
	             	 <option <s:if test="#request.typeId == #t.id">selected</s:if> value="<s:property value="#t.id"/>"><s:property value="#t.name"/></option>
            	</s:iterator>
            </select>
          </div>
        </div>
        <div class="am-u-sm-12 am-u-md-3">
          <div class="am-input-group am-input-group-sm">
            <input type="text" class="am-form-field" id="title">
          <span class="am-input-group-btn">
            <button class="am-btn am-btn-default" type="button" onclick="seek()" >搜索</button>
          </span>
          </div>
        </div>
      </div>
		
		
		
		  <table class="am-table am-table-striped am-table-hover table-main">
              <thead>
              <tr>
                <th class="table-check"><input type="checkbox" /></th><th class="table-id">序号</th><th class="table-title">标题</th><th class="table-type">类别</th><th class="table-author am-hide-sm-only">作者</th><th class="table-date am-hide-sm-only">修改日期</th><th class="table-set">操作</th>
              </tr>
              </thead>
              <tbody>
              <s:iterator value="#request.list" var="item" status="status">
	              <tr>
	                <td><input type="checkbox" /></td>
	                <td><s:property value="#status.index+1"/></td>
	                <td><a href="list_blog"><s:property value="#item.title"/></a></td>
	                <td><s:property value="#item.articleType"/></td>
	                <td><s:property value="#item.name"/></td>
	                <td><s:property value="#item.createTime"/></td>
	                 <td>
	                  <div class="am-btn-toolbar">
	                    <div class="am-btn-group am-btn-group-xs">
	                      <a href="admin_toUpdateArcicle?id=<s:property value="#item.id"/>"><button class="am-btn am-btn-default am-btn-xs am-text-secondary"><span class="am-icon-pencil-square-o"></span> 编辑</button></a>
	                      <a href="#"><button onclick="deleteArticle('<s:property value="#item.id"/>')" class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only"><span class="am-icon-trash-o"></span> 删除</button></a>
	                    </div>
	                  </div>
	                </td>
	              </tr>
	           </s:iterator>
              </tbody>
            </table>
            
            <div class="am-cf">
              共 <s:property value="#request.totalCount"/> 条记录
              <div class="am-fr">
                <ul class="am-pagination">
                
                <%
                	int totalPage =(int) request.getAttribute("totalPage");//总页数
                	int pageNum =(int) request.getAttribute("pageNum");//当前页数
                	
                	String begin ="";
                	String end ="";
                	
                	
                	if(pageNum==1){
                		begin ="class='am-disabled'";
                	}else if(pageNum==totalPage){
                		end ="class='am-disabled'";
                	}
                	%>
                	  <li <%=begin %>><a href="admin_articleList?pageNum=<%=pageNum-1%>">«</a></li>
                	<%
                	
                	for(int i=1;i<=totalPage;i++){
                		String active="";
                		if(pageNum==i){
                			active="class='am-active'";
                		}
                %>
                
                
                  <li <%=active %>><a href="admin_articleList?pageNum=<%=i%>"><%=i%></a></li>
                 
                  
                  <%
                	}
                  %>
                   <li <%=end %>><a href="admin_articleList?pageNum=<%=pageNum+1%>">»</a></li>
                </ul>
              </div>
            </div>
            <hr />
            <p>注：.....</p>
          
        
	</div>
    <hr>
    
  </div>
  
    
</div>

<a href="#" class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu" data-am-offcanvas="{target: '#admin-offcanvas'}"></a>
<!-- 删除提示 -->
<div class="am-modal am-modal-confirm" tabindex="-1" id="my-confirm">
  <div class="am-modal-dialog">
    <div class="am-modal-hd">删除提示</div>
    <div class="am-modal-bd">
      你，确定要删除这条记录吗？
    </div>
    <div class="am-modal-footer">
      <span class="am-modal-btn" data-am-modal-cancel>取消</span>
      <span class="am-modal-btn" data-am-modal-confirm>确定</span>
    </div>
  </div>
 </div>
 
 
<footer>
  <hr>
  <p class="am-padding-left">© 2014 AllMobilize, Inc. Licensed under MIT license.</p>
</footer>

<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="${basePath }assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<!-- http://www.bootcdn.cn/jquery/ -->
<script src="${basePath }assets/js/jquery.min.js"></script>
<!--<![endif]-->
<script src="${basePath }assets/js/amazeui.min.js"></script>
<script src="${basePath }assets/js/app.js"></script>

<script type="text/javascript">

function deleteArticle(id){
	  $('#my-confirm').modal({
        relatedTarget: this,
        onConfirm: function(options) {
        	//http://www.runoob.com/
        	//http://www.w3school.com.cn/
          $.ajax({
        	  url:'${basePath }admin_deleteArticle',
        	  data:{"id":id},
        	  success:function(){
        		 	window.location.reload(); //刷新页面
        	  }
          })
        },
        // closeOnConfirm: false,
        onCancel: function() {
          
        }
      });
}

function seek(){
	var typeId=$("#typeId").val();
	var title=$("#title").val();
	
	window.location.href="admin_articleList?typeId="+typeId+"&title="+title;
	
}
</script>
</body>
</html>